package offer.diff;

import java.util.Arrays;

/**
 * @author DengYuan2
 * @create 2021-03-20 19:55
 */
public class n_66 {
    public static void main(String[] args) {
        n_66 n = new n_66();
        int[] a ={1,2,3,4,5};
        int[] res = n.multiply(a);
        System.out.println(Arrays.toString(res));
    }

    public int[] multiply(int[] A){
        int len= A.length;
        int[] B = new int[len];
        B[0]=1;
        for (int i = 1; i < len; i++) {
            B[i]=B[i-1]*A[i-1];
        }
        int tmp=1;
        for (int i = len-2; i >=0 ; i--) {
            tmp*=A[i+1];
            B[i]=B[i]*tmp;

        }
        return B;
    }


}
